package quoridor;

import quoridor.Player;
import quoridor.Square;
import Util.Constants;

/**
 * Representation of a wall in Quoridor. local variable
 * 'valid' default false, and is set to true once it is
 * determined that placement of the wall does not violate 
 * game rules.
 *   
 * <pre>
 * Initial version (Ashleey - 17/09/2012) 
 *  - created vars players and squares
 *  - created funcs initBoard() and getSquare()
 * </pre>
 * @author Ashleey
 */
public class Board {

	private Player[]   players;
	private Square[][] squares;
	
	public Board() {
		this.players = new Player[Constants.MAX_PLAYERS];
		this.squares = new Square[Constants.BOARD_SIZE][Constants.BOARD_SIZE];
		initBoard();
	}
	
	/**
	 * Initialises each square in the board (total of BOARD_SIZE^2 
	 * initialised
	 */
	private void initBoard() {
		int i, j;
		
		// loop through the 2d Array to create each element
		for (i = 0; i < Constants.BOARD_SIZE; i++)
			for (j = 0; j < Constants.BOARD_SIZE; j++)
				squares[i][j] = new Square();
	}
	
	/**
	 * Returns the square on the board specified by the params 
	 * @param row the row index of the board
	 * @param col the column index of the board
	 * @return the Square at squares[row][col]
	 */
	public Square getSquare(int row, int col) {
		return squares[row][col];
	}

	public Player[] getPlayers() {
		return players;
	}

	public Square[][] getSquares() {
		return squares;
	}
	
	public void setPlayerOne(Player player) {
		this.players[0] = player;
	}
	
	public void setPlayerTwo(Player player) {
		this.players[1] = player;
	}
}
